package cn.heyige.backend.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("member_order")
public class MemberOrderDO {

    @TableId(type = IdType.AUTO)
    private Integer id;
    
    @TableField("user_id")
    private Integer userId;
    
    @TableField("level_id")
    private Integer levelId;

    @TableField("level_name")
    private String levelName;

    @TableField("order_no")
    private String orderNo;
    
    @TableField("status")
    private String status = OrderStatus.PENDING.name();
    
    @TableField("amount")
    private Double amount = 0.0;
    
    @TableField("duration_days")
    private Integer durationDays;
    
    @TableField("paid_time")
    private LocalDateTime paidTime;

    @TableField("remark")
    private String remark;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableField("is_deleted")
    @TableLogic
    private Boolean isDeleted = false;
    
    public enum OrderStatus {
        PENDING,       // 待支付
        PAID,          // 已支付
        CANCELLED,     // 已取消
        REFUNDED,      // 已退款
        FAILED         // 支付失败
    }
}